home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi 2.0 - Programmer's Utilities Power Pack
/
Delphi 2.0 Programmer's Utilities Power Pack.iso
/
a_to_d
/
bigtext
/
bigtext.pas
< prev
Wrap
Pascal/Delphi Source File
|
1996-09-15
|
30KB
|
1,048 lines
unit BigText;
{ TBigText 1.1 (c) 1995 by Gerry Skolnik (skolnik@kapsch.co.at)
Portions (c) 1995 by Danny Thorpe
This is a simple component to display up to 32767 lines of text. Each line
has its own dedicated foreground and background color and can be 255 chars
long. Theoretically this amounts to about 8MB of data and beats the TMemo's
measly 32kB, however, no editing functions are available.
TBigList is a no-frills TList mutant. I've implemented most of the
essential functions. Before fine-tuning I'd like to wait for Windows 95 /
Delphi 95, just in case TBigList is made redundant then.
The limitation of TBigText is caused by the Windows API scrolling functions
insisting on being passed integer values, thus reducing the maximum amount
of lines a scrollbar can handle to 32767. However, display problems start
as soon as line 32750. As I couldn't see much difference between 32750 and
32767 lines, I haven't bothered to track this down. Be my guest.
TBigText is FreeWare. You may use it freely at your own risk in any
kind of environment. This component is not to be sold at any charge, and
must be distributed along with the source code.
The scrolling routines were taken from Danny Thorpe's TConsole object.
BTW: while I claim the copyright to the original source code, this does
not mean that you may not modify or enhance it. Just add your credits,
and if you think you came up with some major improvement that the Delphi
community might find useful, upload it at some Delphi site.
Of course, any enhancement/modification must be released as Freeware.
property MaxLines
if set to 0, as much lines as memory permits are included. The
absolute maximum, however, is 32767. If set to something else,
TBigText will limit itself to that many lines.
property PurgeLines
determines how to handle the situation when no more lines can be
added (line count reached Maxlines value or we ran out of memory).
if set to 0, an exception is raised. If set to something different
(default 200) the number of lines specified by PurgeLines are
deleted, the TBigList objects are packed, and most likely more
lines can be added (though the first ones will be lost).
This option is useful for logging windows.
property Count
run-time read-only. If the Lines and StringColor counts
are equal, this property holds the number of lines in TBigText.
If the two counts are unequal, there's something wrong and the
property holds a value of -1.
procedure AddLine(LineString: string; FCol, BCol: TColor;
UpdateDisplay: boolean);
The essential routine to insert lines into TBigText.
LineString : the text to be inserted
FCol : forground color
BCol : background color
UpdateDisplay: if true, TBigText will scroll to the last line
(where the new line will be added), and update
its display. This is not recommended if lots of
lines are to be included in a loop.
procedure LoadFromFile(FileName: TFileName);
Loads a file into TBigText. Every line will have the default colors
clWindowText, clWindow.
procedure Print
prints all lines on the specified printer. Haven't
checked this out, though.
procedure ChangeColor(Index: longint; OldFCol, OldBCol, NewFCol,
NewBCol: TColor);
changes the colors of the line at Index, but only if the
current colors match OldFCol and
OldBCol (FCol = foreground color, BCol = background color).
the following procedures do pretty much the same as
the accodring TList methods:
procedure Clear;
procedure Delete(Index: longint);
procedure Remove(Index: longint);
procedure Pack;
*****************************************************************
Function Search - Added EJH 07/04/95
Search('this text', True, True);
Parameters:
SrcWord : String - What to Look for in the array
SrchDown : Bool - True - Search down; False - Search Up
MCase : Bool - True - Match Case Exact; False - Disregard Case
Returns: True - Found ; False - Not Found
Note: This is a little screwy because it does not redisplay the
last page if text is found there when already on the last page.
Also, during displays of found data, on the last call, if the
user closes the finddialog, I could not see an automatic way
for this application to know that it was not visible, so the
final blue line stays on the screen untill the window scrolls
beyond it, from then on it is not there. This is sometimes
useful, othertimes it is just ugly.
Note: To find exact matches if you have the option available to the
user, put a space on both sides of SrcWord, otherwise partial
matches are used.
Modifications - Eric Heverly - July 1995 (erichev@ix.netcom.com)
Scroll- Added keys F1-F4 to the Scrool Keys table.
Print - Added canvas font for the display canvas to the printer
so the expected printer font was the same. Also added some
Cursor := crHourGlass to show that the system was busy during
print cycles.
Search- Added function.
GoPosi- GoPosition function added.
LoadFr- LoadFromFile added some Cursor := crHourGlass to show the
user that the system is busy. Also I changed the call to the
addline function to use the dumchar, this keeps the font to
the defined font in the object editor (ie. I used Courier and
this way it kept Courier as the display font, with the OEM
characters, it always used the System font).
}
interface
uses WinTypes, WinProcs, Messages, Classes, Controls, Printers,
Forms, Graphics, SysUtils;
type
{$M+}
TStringColor = class
public
FColor : TColor;
BColor : TColor;
end;
TBigList = class
private
function GetCapacity: longint;
function GetCount: longint;
function GetItems(Index: longint): pointer;
procedure SetItems(Index: longint; const Item: pointer);
protected
ListCount : LongInt;
TheLines : array[0..3] of TList;
published
property Capacity: longint read GetCapacity;
property Count: longint read GetCount;
public
property Items[Index: longint]: pointer read GetItems write SetItems;
constructor Create;
destructor Destroy;
class function ClassName: string;
function Add(Item: Pointer): longint;
procedure Delete(Index: longint);
procedure Remove(Index: longint);
procedure Pack;
procedure Clear;
function First: pointer;
function Last: pointer;
end;
{$M-}
TBigText = class(TCustomControl)
private
FFont: TFont;
FMaxLines: word;
FPurgeLines: word;
FColor : TColor;
procedure DoScroll(Which, Action, Thumb: LongInt);
procedure WMHScroll(var M: TWMHScroll); message wm_HScroll;
procedure WMVScroll(var M: TWMVScroll); message wm_VScroll;
procedure WMSize(var M: TWMSize); message wm_Size;
procedure WMGetDlgCode(var M: TWMGetDlgCode); message wm_GetDlgCode;
procedure SetFont(F: TFont);
function GetCount: longint;
protected
FRange: TPoint;
FOrigin: TPoint;
FClientSize: TPoint;
FCharSize: TPoint;
FOverhang: LongInt;
FPageSize: LongInt;
Lines: TBigList;
StringColor: TBigList;
procedure Paint; override;
procedure SetScrollbars;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
published
proced